package com.example.changeactivity03_2;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;

public class ActList extends ListActivity {
	String[] l_strs={"Marco","Tom","Jason","Selina","Mark","July",
			"Mary","Bill","Jacky","Wang","Matt",
			"Marian","Bily","Jack","Wan","Mati",
			"Joey","Bruce","MainChu","WudwenYee","Sun"};

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		Log.i("SELECT_ITEM",String.valueOf(position));
		super.onListItemClick(l, v, position, id);
		//選點之後傳值回去給主頁面選
		Bundle bund = new Bundle();
		//l_strs[position]代表點選到哪個位子
		bund.putString("GG", l_strs[position]);
		Intent intent = new Intent();
		intent.putExtras(bund);
		setResult(0, intent);

		finish();
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//跟ListView有關係,我們們使用這方法,來顯示我們List的資料
		ListAdapter l_listAdapter=new ArrayAdapter<String>(
				this,
				android.R.layout.simple_list_item_1,
				l_strs);
		//顯示List
		setListAdapter(l_listAdapter);

	}

}
